import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.JFileChooser;


public class Thread2 implements Runnable
{
	public void run()
	{
		JFileChooser chsr = new JFileChooser();
		chsr.showOpenDialog(null);
		File file = chsr.getSelectedFile();
		String fileName="";
		try 
		{
			fileName = file.getCanonicalPath();
			String path="";
			path=file.getCanonicalPath();
			System.out.print(path);
		} catch (IOException e) 
		{				
			e.printStackTrace();
		}
		
		
		// READ LINES OF THE SELECTED FILE
		try 
		{
			readFileAndOutputToScreen(fileName);
		} catch (IOException e) 
		{				
			e.printStackTrace();
		}
	}
	void readFileAndOutputToScreen(String fileName) throws IOException
	{
			
			FileReader reader = null;
			try 
			{
				reader = new FileReader(fileName);
			} catch (FileNotFoundException e)
			{
				e.printStackTrace();
			}
			
	        BufferedReader in = new BufferedReader(reader);
	        String line = "";
	        
	        try {
				while ((line = in.readLine()) != null) {
				    System.out.println(line);
				}
			} catch (IOException e) {			
				e.printStackTrace();
			}
	        
	        in.close();
		}

	}

